package cn.codeforfun.controller;

import cn.codeforfun.entity.User;
import cn.codeforfun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * Created by Administrator on 2017/2/25.
 */
@RestController
@RequestMapping("/user")
public class UserController {
  @Autowired
  private UserService userService;


  @RequestMapping(value = "/save", method = RequestMethod.POST)
  public void save(@RequestBody User user) {
    userService.save(user);
  }

  @RequestMapping(value = "/findOne/{id}", method = RequestMethod.GET)
  public User findOne(@PathVariable String id) {
    return userService.findOne(Long.valueOf(id));
  }

  @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
  public void delete(@PathVariable String id) {
    userService.delete(Long.valueOf(id));
  }
}
